home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: clamage@Eng.sun.com (Steve Clamage)
- Newsgroups: comp.std.c++
- Subject: Re: order of evaluation
- Date: 22 Jan 1996 17:22:42 GMT
- Organization: Sun Microsystems Inc.
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <4e0gpg$4dp@engnews1.Eng.Sun.COM>
- References: <4e0dr0$aul@rznews.rrze.uni-erlangen.de>
- Reply-To: clamage@Eng.sun.com
- NNTP-Posting-Host: taumet.eng.sun.com
- Content-Type: text
- X-Nntp-Posting-Host: taumet.eng.sun.com
- Content-Length: 1513
- X-Lines: 39
- Originator: clamage@taumet
-
- In article aul@rznews.rrze.uni-erlangen.de, anhaeupl@late.e-technik.uni-erlangen.de (Bernd Anhaeupl) writes:
- >In various places the DWP specifies, that the order of evaluation of
- >some expressions is unspecified.
-
- >1.) Does this mean, that for example in the following function call
- >
- > f(a(...),b(....),c(....));
- >
- > a(...), b(...), c(...) may even be evaluated in parallel in a
- > multitasking environment?
-
- No. Section 1.8 says function calls may not be interleaved. In your
- example, "a", "b", and "c" may be called in any order, but whichever
- one is called first must complete before the second one is called.
- (The C++ language definition does not address parallelizing of program
- execution, but we can talk about interleaving parts of expressions.)
-
-
- >2.) Is it legal for a compiler to reorder the evaluation of
- > the operator new and the constructor calls of some new expressions.
- > For example, is it legal for a compiler to evaluate
-
- > f(new a(new b())) or f2(new a, new b) (see also question 1)
- >
- > in the following order:
-
- > tmp1=a::new(sizeof(a)); tmp1=a::new(sizeof(a))
- > tmp2=b::new(sizeof(b)); tmp2=b::new(sizeof(b))
- > tmp2.b(); tmp1.a()
- > tmp1.a(tmp2); tmp2.b()
- > f(tmp1); f2(tmp1,tmp2);
-
- I believe the reordering is allowed, because I don't think there is
- any sequence point that prevents it.
-
- ---
- Steve Clamage, stephen.clamage@eng.sun.com
-
-
-
- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
- Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
- is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
-
-